package com.example.business.controller;

import com.example.common.response.PageResponse;
import com.example.common.response.R;
import com.example.business.request.SbOrderItemListRequest;
import com.example.business.response.SbOrderItemResponse;
import com.example.business.service.SbOrderItemService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.business.request.SbOrderItemRequest;
import java.util.List;

@RestController
@RequestMapping("sb-order-item")
public class SbOrderItemController {
    @Autowired
    SbOrderItemService sbOrderItemService;

    @GetMapping("list")
    public R<PageResponse<SbOrderItemResponse>> list(@Valid SbOrderItemListRequest request) {
        PageResponse<SbOrderItemResponse> list = sbOrderItemService.list(request);
        return R.ok(list);
    }

    @PostMapping("save")
    public R<Object> save(@Valid @RequestBody SbOrderItemRequest request) {
        sbOrderItemService.save(request);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R<Integer> delete(@RequestBody List<Long> ids) {
        int result = sbOrderItemService.deleteBatch(ids);
        return R.ok(result);
    }
}
